/*
 * @lc app=leetcode.cn id=2129 lang=golang
 *
 * [2129] 将标题首字母大写
 */
package Solutions

import (
	"fmt"
	"strings"
)

// @lc code=start
func capitalizeTitle(title string) string {
	subStrs := strings.Split(title, " ")
	sb := strings.Builder{}
	for i := 0; i < len(subStrs); i++ {
		subStrs[i] = strings.ToLower(subStrs[i])
		if len(subStrs[i]) >= 3 {
			t := []byte(subStrs[i])
			if t[0] >= 'a' {
				t[0] = t[0] - 32
			}
			fmt.Println(t)
			sb.WriteString(string(t))
			sb.WriteByte(' ')
		} else {
			sb.WriteString(subStrs[i])
			sb.WriteByte(' ')
		}

	}
	return sb.String()[:sb.Len()-1]
}

// @lc code=end
